package com.gjy.concurrency.hc;

import com.gjy.util.ThreadUtil;
import org.junit.jupiter.api.Test;

import java.util.HashSet;
import java.util.concurrent.ConcurrentSkipListSet;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * @author 宫静雨
 * @version 1.0
 * @since 2023-03-30 14:00:57
 */
public class HcTest1 {

    private HashSet<Integer> hashSet = new HashSet<>();
    private ConcurrentSkipListSet<Integer> css = new ConcurrentSkipListSet<>();

    @Test
    public void test1() {
        ThreadPoolExecutor pool = ThreadUtil.defaultPool();
        for (int i = 0; i < 100000; i++) {

            int median = i;
            pool.execute(() -> css.add(median));
        }

        pool.shutdown();

        System.out.println("hashSet.size() = " + css.size());
    }

}
